// Content.java

package com.ruoyi.hospital.entity.order;

import com.ruoyi.service.domain.ServiceOrders;
import com.ruoyi.service.domain.ServicePay;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;

@lombok.Data
public class HospitalOrderReturnVO {
    private Long orderId;
    private String orderIdVO;
    private String orderStatus;
    private String orderCode;
    private String createDate;
    private String expireTime;

    private Long prePaid;
    private Long actualPaid;
    private Long returnAmount;
    private Long suppleAmount;

    private String verifiCode;

    private List<HospitalOrderInfo> orderInfo;
    private List<HospitalOrderButton> buttons;

    private HospitalDispatchInfo dispatchInfo;
    private HospitalProofsInfo proofsInfo;

    private HospitalServeInfo serveInfo;

    //private String orderPayTip = "请在 30分钟 内完善信息并支付，否则订单将会失效";
    //private String orderProcessTip = "您的订单东华数字医院已经受理，资料审核并指派护士中，请保持电话畅通，耐心等待。";

    public void init(ServiceOrders order) throws ParseException {
        this.setOrderId(order.getOrderId());
        this.setOrderIdVO(order.getOrderCode());
        switch (order.getOrderServiceflag()){
            case 3:
            case 5:
            case 6:
            case 7:
                this.setOrderCode("new");
                this.setOrderStatus("新订单");
                break;
            case 8:
                this.setOrderCode("unserved");
                this.setOrderStatus("待服务");
                break;
            case 9:
            case 10:
            case 11:
                this.setOrderCode("serving");
                this.setOrderStatus("服务中");
                break;
            case 12:
            case 13:
                this.setOrderCode("unsettled");
                this.setOrderStatus("结算中");
                break;
            //case 14:
            //case 15:
            //case 16:
            //case 17:
            //    this.setOrderCode("settled");
            //    this.setOrderStatus("已结算");
            //    break;
            case 2:
                this.setOrderCode("canceled");
                this.setOrderStatus("已退单");
                break;
            case 4:
                this.setOrderCode("canceled");
                this.setOrderStatus("已退单");
                break;
        }

        Date creatTime = order.getOrderCreatetime();
        if (creatTime != null){
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(creatTime);
            calendar.add(Calendar.MINUTE, 30);
            Date expireTime = calendar.getTime();

            DateFormat cstFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            DateFormat gmtFormate = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);

            String creatTimeNew = cstFormate.format(creatTime);
            String expireTimeNew = cstFormate.format(expireTime);

            this.setCreateDate(creatTimeNew);
            this.setExpireTime(expireTimeNew);
        }
    }

    public void initPay(ServicePay payInfo) {
        this.setPrePaid(payInfo.getPayAdvancepay());
        this.setActualPaid(payInfo.getPayActualpay());
        if(payInfo.getPayDifference() != null){
            if(payInfo.getPayDifference() < 0){
                this.setReturnAmount(payInfo.getPayDifference());
            }else {
                this.setSuppleAmount(payInfo.getPayDifference());
            }

        }
    }

}